<?php 
	/**
	 * 定义一个矩形类，这个类要按照形状的规范去实现
	 */

	class Rect extends Shape {

		private $width;
		private $height;
		public $from = "";
		public $arr=array('width'=>0, 'height'=>0);



		public function __construct($arr=array()){
			
			if(!empty($arr)){
				$this->height = $arr['height'];
				$this->width = $arr['width'];
			}
			$this->name = "矩形";
		}

		function area(){
			return $this->width * $this->height;
		}

		function zhou(){
			return 2*($this->width + $this->height);
		}

		/**
		 * [View description]
		 * @return [type] [description]
		 */
		public function view() {
			if($_POST){
				$width1 = $_POST['width'];
				$height1 = $_POST['height'];
			}else{
				$width1 = "请你输入宽";
				$height1 = "请你输入高";
			}
			$from = '<form action="index.php?action=rect" method="post">'.$this->name.'的宽：
					<input type="text" name="width" value="'.$width1.'" /><br />'.$this->name.'的高：
					<input type="text" name="height" value="'.$height1.'" /><br />
					<input type="submit" name="dosubmit" value="计算" /></form>';
			echo $from;
		}

		public function yan($arr){
			$bg = 0;
			if ($arr['width'] <= 0) {
				echo $this->name."的宽度不能小于0<br>";
				$bg = false;
			}else{
				$bg = true;
			}
			if ($arr['height'] <= 0) {
				echo $this->name."的高度不能小于0<br>";
				$bg= false;
			}else{
				$bg = true;
			}

			return $bg;
			
		}
	}



 ?>